"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var QRCodeDialog = /** @class */ (function (_super) {
    __extends(QRCodeDialog, _super);
    function QRCodeDialog(props) {
        var _this = _super.call(this, props) || this;
        _this.state = { scaned: false };
        return _this;
    }
    QRCodeDialog.prototype.componentDidMount = function () {
        ui.renderImage(this.img, { imageText: '正在生成二维码' });
        this.dialogContainer = this.dialogElement.parentElement;
    };
    QRCodeDialog.prototype.render = function () {
        var _this = this;
        var _a = this.props, title = _a.title, tips = _a.tips;
        var scaned = this.state.scaned;
        return (React.createElement("div", { className: "modal-dialog", style: { width: 400 }, ref: function (e) { return _this.dialogElement = e || _this.dialogElement; } },
            React.createElement("div", { className: "modal-content" },
                React.createElement("div", { className: "modal-header" },
                    React.createElement("button", { type: "button", className: "close", onClick: function () {
                            _this.hide();
                        } },
                        React.createElement("span", { "aria-hidden": "true" }, "\u00D7")),
                    React.createElement("h4", { className: "modal-title" }, title)),
                React.createElement("div", { className: "modal-body form-horizontal" },
                    React.createElement("div", { className: "qrcodeElement", ref: function (e) { return _this.qrcodeElement = e; } },
                        React.createElement("img", { style: { width: '100%' }, ref: function (e) { return _this.img = e || _this.img; } }))),
                React.createElement("div", { className: "modal-footer", style: { textAlign: 'center' } }, scaned ?
                    React.createElement("h4", null,
                        React.createElement("i", { className: "icon-ok text-success", style: { fontSize: 'larger' } }),
                        React.createElement("span", { style: { paddingLeft: 8 } }, "\u5DF2\u626B\u63CF\u4E8C\u7EF4\u7801")) :
                    React.createElement("h4", null, tips)))));
    };
    QRCodeDialog.prototype.show = function () {
        ui.renderImage(this.img, { imageText: '正在生成二维码' });
        ui.showDialog(this.dialogContainer);
    };
    QRCodeDialog.prototype.hide = function () {
        ui.hideDialog(this.dialogContainer);
    };
    QRCodeDialog.prototype.setUrl = function (url) {
        console.assert(this.qrcodeElement != null);
        var qrcode = new QRCode(this.qrcodeElement.parentElement, { width: 200, height: 200, text: "" });
        var q = qrcode;
        q._oDrawing._elImage = this.qrcodeElement.querySelector('img');
        console.log(url);
        qrcode.makeCode(url);
        this.state.scaned = false;
        this.setState(this.state);
    };
    return QRCodeDialog;
}(React.Component));
exports.QRCodeDialog = QRCodeDialog;
var QRCodeImage = /** @class */ (function (_super) {
    __extends(QRCodeImage, _super);
    function QRCodeImage(props) {
        var _this = _super.call(this, props) || this;
        _this.state = { scaned: false };
        return _this;
    }
    QRCodeImage.prototype.componentDidMount = function () {
        this.clear();
    };
    QRCodeImage.prototype.render = function () {
        var _this = this;
        var tips = this.props.tips;
        var scaned = this.state.scaned;
        return (React.createElement("div", { key: 10, className: "qrcodeElement", ref: function (e) { return _this.element = e; } },
            React.createElement("div", null,
                React.createElement("img", { style: { width: '80%' }, ref: function (e) { return _this.img = e || _this.img; } })),
            React.createElement("div", { key: 20, style: { textAlign: 'center' } }, scaned ?
                React.createElement("h4", null,
                    React.createElement("i", { className: "icon-ok text-success", style: { fontSize: 'larger' } }),
                    React.createElement("span", { style: { paddingLeft: 8 } }, "\u5DF2\u626B\u63CF\u4E8C\u7EF4\u7801")) :
                React.createElement("h4", null, tips))));
    };
    QRCodeImage.prototype.clear = function () {
        ui.renderImage(this.img, { imageText: '正在生成二维码' });
    };
    QRCodeImage.prototype.setUrl = function (url) {
        console.assert(this.element != null);
        var qrcode = new QRCode(this.element, { width: 200, height: 200, text: "" });
        var q = qrcode;
        q._oDrawing._elImage = this.img; //this.element.querySelector('img');
        console.log(url);
        qrcode.makeCode(url);
        this.state.scaned = false;
        this.setState(this.state);
    };
    QRCodeImage.prototype.show = function () {
        this.element.style.removeProperty('display');
    };
    QRCodeImage.prototype.hide = function () {
        this.element.style.display = "none";
    };
    return QRCodeImage;
}(React.Component));
exports.QRCodeImage = QRCodeImage;
